import java.awt.event.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;

/**
 * Remote control server.
 */
class Nintendo extends LocalServer {

  public interface NintendoReceiver {
    void up();
    void down();
    void left();
    void right();
    void select();
    void start();
    void a();
    void b();
  }

  private final static NintendoReceiver DUMMY_RECEIVER 
    = new NintendoReceiver() {
        public void up() {System.out.println("up");}
        public void down() {System.out.println("down");}
        public void left() {System.out.println("left");}
        public void right() {System.out.println("right");}
        public void select() {System.out.println("select");}
        public void start() {System.out.println("start");}
        public void a() {System.out.println("a");}
        public void b() {System.out.println("b");}
      };

  private final NintendoReceiver receiver;
  Nintendo(NintendoReceiver receiver) {
    this.receiver = receiver;
  }

  protected boolean showIP() {return true;}

  private abstract class NintendoHandler extends AbstractHandler {
    NintendoHandler() {
      super();
    }
  }

  private class Up extends NintendoHandler {
    Up() {super();}
    public String handle(Map<String,String> args) {
      receiver.up();
      return OK;
    }
  }

  private class Down extends NintendoHandler {
    Down() {super();}
    public String handle(Map<String,String> args) {
      receiver.down();
      return OK;
    }
  }

  private class Left extends NintendoHandler {
    Left() {super();}
    public String handle(Map<String,String> args) {
      receiver.left();
      return OK;
    }
  }
  
  private class Right extends NintendoHandler {
    Right() {super();}
    public String handle(Map<String,String> args) {
      receiver.right();
      return OK;
    }
  }

  private class Select extends NintendoHandler {
    Select() {super();}
    public String handle(Map<String,String> args) {
      receiver.select();
      return OK;
    }
  }

  private class Start extends NintendoHandler {
    Start() {super();}
    public String handle(Map<String,String> args) {
      receiver.start();
      return OK;
    }
  }

  private class B extends NintendoHandler {
    B() {super();}
    public String handle(Map<String,String> args) {
      receiver.b();
      return OK;
    }
  }
  
  private class A extends NintendoHandler {
    A() {super();}
    public String handle(Map<String,String> args) {
      receiver.a();
      return OK;
    }
  }


  Handler[] getHandlers() {
    return new Handler[] {
      new Up(),
      new Down(),
      new Left(),
      new Right(),
      new Select(),
      new Start(),
      new B(),
      new A(),
    };
  }

  public static void main(String args[]) {
    new Nintendo(DUMMY_RECEIVER).realMain(args);
  }
  
}
